<?php session_start() ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Let's roll some dice!</title>
</head>
	<body>
	<h2><i>Let's roll some dice!</i></h2>
	<br />
	<?php
	$k = $_POST['number'];
	$tipo = $_POST['tipo'];
	$voluntad = $_POST['voluntad'];
	if ($tipo == "attack"){
		for ($i = 1; $i <= $k; $i++) {
			$roll = mt_rand(1,6);
			echo "<img src='images/dice{$roll}.png' alt='$roll' /> ";
		}	
	}elseif ($tipo == "other"){
			$roll1 = mt_rand(1,10);
			$roll2 = mt_rand(1,10);
			echo $roll1;
			echo "+";
			echo $roll2;
			echo "=".($roll1+$roll2);
	}elseif ($tipo == "vol"){
			$roll3 = mt_rand(1,100);
			if($voluntad != ""){
			if($voluntad < $roll3)
			{
				echo "Te falla la voluntad.<br />";
				echo $voluntad.">".$roll3;
			}
			elseif($voluntad >= $roll3)
			{
				echo "Tu voluntad es inquebrantable.<br />";
				echo $voluntad."<".$roll3;
			}
			}
			}
			
	?>
	
	
	<p><i>How many dice to roll</i></p>
		<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
		<!-- this can only be an integer -->
		<input type="text" name='number' />
		<label>Voluntad</label>
		<input type="text" name='voluntad' />

		<SELECT NAME="tipo" SIZE=1 onChange=""> 
			<OPTION VALUE="attack">Ataque</OPTION>
			<OPTION VALUE="skill">Habilidad</OPTION>
			<OPTION VALUE="talent">Talento</OPTION>
			<OPTION VALUE="vol">Voluntad</OPTION> 
			<OPTION VALUE="other">Otro</OPTION> 
		</SELECT> 
		
		<input type="submit" value="Roll the dice!" />
		</form>
	</body>
</html>